package com.hsnn.medstgmini.trading.pur.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hsnn.medstgmini.trading.pur.dao.PurOrderInfoOldDao;
import com.hsnn.medstgmini.trading.pur.model.OrderPackStatus;
import com.hsnn.medstgmini.trading.pur.service.PurOrderInfoOldManager;
import com.hsnn.medstgmini.util.Pagination;

@Service
public class PurOrderInfoOldManagerImpl implements PurOrderInfoOldManager {

	@Autowired
	private PurOrderInfoOldDao purOrderInfoOldDao;

	@Override
	public Pagination getOrdersDetailListOldByHosp(Pagination page) {
		return purOrderInfoOldDao.getOrdersDetailListOldByHosp(page);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pagination getOrdersDetailListOld(Pagination page) {
		page = purOrderInfoOldDao.getOrdersDetailListOld(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page
				.getRows();
		if (null != list && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> map = list.get(i);
				map.put("orderStatus",map.get("orderStatus") == null ? "":OrderPackStatus.getName(Integer.valueOf(map.get("orderStatus").toString())));
			}
		}
		return page; 
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pagination getOrdersDetailListOldByProComp(Pagination page) {
		page = purOrderInfoOldDao.getOrdersDetailListOldByProComp(page);
		List<Map<String, Object>> list = (List<Map<String, Object>>) page
				.getRows();
		if (null != list && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> map = list.get(i);
				map.put("orderStatus",map.get("orderStatus") == null ? "":OrderPackStatus.getName(Integer.valueOf(map.get("orderStatus").toString())));
			}
		}
		return page; 
	}

	@Override
	public Pagination getOrdersDetailListOldByComp(Pagination page) {
		return purOrderInfoOldDao.getOrdersDetailListOldByComp(page);
	}
	
}
